import { TEXT } from './const'
function createElement(type, config, ...children) {
    if (config) {
        delete config.__self
        delete config.__source
    }
    const props = {
        type,
        ...config,
        children: children.map((child) =>
            typeof child === 'object' ? child : createTextNode(child)
        ),
    }
    return {
        type,
        props,
    }
}

function createTextNode(child) {
    return {
        type: TEXT,
        props: {
            children: [],
            nodeValue: child,
        },
    }
}

export default {
    createElement,
}
